package com.softer.chengxin.param.dao;

import com.softer.chengxin.param.dao.provider.ParamDaoProvider;
import com.softer.chengxin.param.entity.ParamVO;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author Gong Zhiyang
 * @date 2019/12/11
 */
@Mapper
@Repository
public interface ParamDao {
    /**
     * 修改参数
     *
     * @param paramVO 参数
     * @return 修改结果
     */
    @Update("UPDATE param SET param_value=#{p.paramValue},unit=#{p.unit},remark=#{p.remark},gmt_modify=now() WHERE id=#{p.id}")
    int update(@Param("p") ParamVO paramVO);

    /**
     * 获取参数详情
     *
     * @param id 参数Id
     * @return 参数详情
     */
    @Select("SELECT id, param_value as paramValue,param_key as paramKey,param_name as paramName,unit,remark,gmt_modify as gmtModify FROM param WHERE id =#{id}")
    ParamVO getInfo(int id);

    /**
     * 获取参数列表
     *
     * @param paramVO 查询实体
     * @return 参数列表
     */
    @SelectProvider(type = ParamDaoProvider.class, method = "getList")
    List<ParamVO> getList(@Param("p") ParamVO paramVO);

    /**
     * 获取参数详情
     *
     * @param paramKey 参数键
     * @return 参数详情
     */
    @Select("SELECT id, param_value as paramValue,param_key as paramKey,param_name as paramName,unit,remark,gmt_modify as gmtModify FROM param WHERE param_key =#{key}")
    ParamVO getParma(@Param("key") String paramKey);
}
